import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant from 'vant';
import 'vant/lib/index.css';
import axios from 'axios'
import Vueaxios from 'vue-axios'
import server from './config/server'
import ws from './websocket/ws'

Vue.use(Vueaxios, axios)
Vue.use(Vant);

Vue.prototype.server = server;
Vue.prototype.ws = ws;

Vue.config.productionTip = false

axios.interceptors.request.use(
  config => {
    if (localStorage.getItem('token')) {
      config.headers.Authorization = 'Bearer ' + localStorage.getItem('token');
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);

var vue = new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

export default vue